//
//  BaseEntity.h
//  KoalaKnow
//  
//  Created by sally on 16/1/22.
//  Copyright © 2016年 szjn. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DatabaseSetting.h"
#import <FMDB.h>

typedef enum : NSUInteger {
  SyncStateNormal     = 0,
  SyncStateNeedUpload = 1,
  SyncStateDelete     = 2,
} EntitySyncState;

@interface BaseEntity : NSObject

@property (nonatomic, assign, getter=isNewRecord) BOOL newRecord;

- (instancetype)init;
- (instancetype)initWithDBSet:(FMResultSet *)set;
+ (NSArray *)arrayWithDBSet:(FMResultSet *)set;

- (BOOL)save;

// Override in sub-class
- (BOOL)insert;
- (BOOL)modify;
- (BOOL)delete;

// Use in sub-class
+ (BOOL)open;
+ (BOOL)close;
+ (FMDatabase *)database;
- (BOOL)open;
- (BOOL)close;
- (FMDatabase *)database;

@end
